#ifndef LINESTRIPE_H
#define LINESTRIPE_H

#pragma warning(disable:4251)

#include <BLine>
#include <BSphere>
#include <BCone>

using namespace BWE;

class LineStripe :public BShape
{
	BOBJECT(LineStripe)
public:
	LineStripe();
	LineStripe(const BVectorArray& linePoints);
	~LineStripe();

	virtual void copy(const BShape* other) override;
	virtual BShape* clone() const override;

	BLine line(BReal value) const;
	BVector vertex(BReal value) const;
	BReal value(const BVector& point) const;

	BReal length() const;
	BReal headLength() const;
	BReal tailLength() const;

	bool closeLoop() const;
	bool reverse();

	void setLinePoints(const BVectorArray& linePoints);
	const BVectorArray& linePoints() const;

	int pointCount() const;

	bool setPoint(int index, const BVector& point);
	const BVector& point(int index) const;

	void setThickness(BReal thickness);
	BReal thickness() const;

	bool appendPoint(const BVector& point);
	bool removePoint(int index);

	const BVector& head() const;
	const BVector& tail() const;
	
	void setHeadColor(const BColor& headColor);
	const BColor& headColor() const;

	void setHeadVisible(bool visible);
	bool headVisible() const;

	void setTailColor(const BColor& tailColor);
	const BColor& tailColor() const;

	void setTailVisible(bool visible);
	bool tailVisible() const;

	bool extendHead(LineStripe* track);
	bool extendTail(LineStripe* track);

	LineStripe* headTrack() const;
	LineStripe* tailTrack() const;

	using BShape::query;
	virtual bool query(const BString& text, BValue& value) const;

protected:
	void slotTransformed(const BObject* object, const BValue& value);

protected:
	virtual void refresh(BBox& box);
	virtual void render(BRender& render);

private:
	BReal				_thickness;
	BHolder<BSphere>	_headSphere;
	BHolder<BCone>		_tailCone;

	BVectorArray			_linePoints;
	mutable BReal			_length;
	BHolder<LineStripe>		_headTrack;
	mutable BReal			_headLength;
	BHolder<LineStripe>		_tailTrack;
	mutable BReal			_tailLength;
};

#endif
